package day1;

import org.junit.Test;

import java.util.Arrays;
import java.util.Random;

public class RandomArrayTest {















    @Test
    public void test01(){
        int count=0;
        while(count<10){
            int [] arr= randomArray(6,7);
            System.out.println(Arrays.toString(arr));
            count++;
        }
    }


    public int[] randomArray(int length,int bound){
        int [] arr=new int[length];
        Random r=new Random();
        for(int i=0;i<arr.length;i++){
            int temp =r.nextInt(bound)+1;
            boolean flag=true;
            for(int j=i-1;j>=0;j--){
                if(arr[j]== temp){
                    System.out.println("发现重复数据");
                    i--;
                    flag=false;
                    break;

                }
            }
            if(flag){
                arr[i]=temp;
            }
        }
        return arr;
    }
}
